<?php 
include_once('connection/connection.php');
include('header.php');
include('menu.php');
include('config.php');

$frm=$_REQUEST['form_id'];
 	if(isset($_REQUEST['form_id'])){
	 $_SESSION['frm_unique_id']=$frm;
 	}
 	$frm =  $_SESSION['frm_unique_id'];
	
function getName($colName,$id)
{
	$sqlgetName="select distinct ".$colName."_name from tbl_lookup_location where ".$colName."_id=".$id;
	$querygetName=mysql_query($sqlgetName);
	$rowgetName=mysql_fetch_row($querygetName);
	return $rowgetName[0];
}
//$frm=998;//$_SESSION['form_id'];
$qryMain="select * from tbl_dtls_q2_main where id='$frm'";
$resMain=mysql_query($qryMain);
$rowMain=mysql_fetch_array($resMain);
$dis=$rowMain['district_id'];
$dis_name=getName('district',$dis);
$_SESSION['dis_name']=$dis_name;
$tehsil=$rowMain['tehsil_id'];
$id1=$rowMain['id'];
$_SESSION['id1']=$id1;
?>
<!-- face file start -->
<script src="facefiles/jquery-1.2.2.pack.js" type="text/javascript"></script>
<link href="facefiles/facebox.css" media="screen" rel="stylesheet" type="text/css" />
<script src="facefiles/facebox.js" type="text/javascript"></script>

<script type="text/javascript">
    jQuery(document).ready(function($) {
      $('a[rel*=facebox]').facebox() 
    })
</script>
<!-- end face file -->
<style type="text/css">
<!--
.heading_bgclr{
background-color:#999999;
}
.section_heading
{
	border:#666666 1px solid;
	width:780px;
	height:22px;
	color:#FFFFFF;
	font-family:arial;
	font-size:13px;
	font-weight:700;

}
.section_format
{
	background:#FFFFFF;
	width:780px;
}
.section_format table
{
	border-collapse:collapse;
	border-color:#666666;
	background-color:#EEEEEE;
	width:780px;
}
.section_format
{
	font-size:8.5pt;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	color:#000000;
}
.section_format td
{
	height:25px;
}
-->
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="animatedcollapse.js"></script>

<script type="text/javascript">

animatedcollapse.addDiv('section1', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section2', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section3', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section4', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section5', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section6', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section7', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section8', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section9', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section10', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section11', 'fade=1,height=0px,persist=1,hide=1')
animatedcollapse.addDiv('section12', 'fade=1,height=0px,persist=1,hide=1')

animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
	//$: Access to jQuery
	//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
	//state: "block" or "none", depending on state
}

animatedcollapse.init()
</script>
<script language=javascript>
function display(val)
{
	//alert(val);
	//for(i=1; i<=total; i++)
	//{ 
		if(val == "NOT FUNCTIONAL")
		{
		//alert("if part");
			document.getElementById('showMydiv').style.display = "none";
			document.getElementById('hideMydiv').style.display = "block";
			/*
			document.getElementById('opration_status').disabled=true;	
			document.getElementById('quality_status').disabled=true;	
			document.getElementById('yield').disabled=true;
			document.getElementById('seasonal_flunctuation').disabled=true;
			document.getElementById('fluctuation_min').disabled=true;
			document.getElementById('fluctuation_max').disabled=true;
			*/
		}	
		else
		{
		//alert("else part");
			document.getElementById('showMydiv').style.display = "block";
			document.getElementById('hideMydiv').style.display = "none";
			/*
			var chks = document.getElementsByName('repairable_status');
			var hasChecked = false;
			for(var j=0; j<chks.length; j++)
			{
				if(chks[j].checked)
				{
					chks[j].checked=false;
				}
			}
			document.getElementById('remarks').value="";
			document.getElementById('nonFuncDiv').style.display = "none";
			document.getElementById('opration_status').disabled=false;	
			document.getElementById('quality_status').disabled=false;	
			document.getElementById('yield').disabled=false;
			document.getElementById('seasonal_flunctuation').disabled=false;
			document.getElementById('fluctuation_min').disabled=false;
			document.getElementById('fluctuation_max').disabled=false;
			*/
		}
}
</script>

<div align="center" id="main_div">
<table border="0" width="786" id="main_table" align="center" style="padding:10px;">
<tr><td width="780" background="images/title.gif"> 
   <a href="javascript:animatedcollapse.toggle('section1')">
   <div class="section_heading">&nbsp;1. Scheme Details</div></a>
 </td> </tr>
  <tr><td>
   <div id="section1" class="section_format">	
  <table border="1">
    <tr>
      <td colspan="2" align="right"><div style="float:right; padding-right:5px; border-left:1px solid #CCCCCC; width:35px"><a href="scheme_detail_edit_q2.php?var=<?php echo $frm;?>" rel="facebox" style="text-decoration:none"><img src="images/edit.gif" border="0" title="EDIT RECORD" /></a></div></td>
      </tr>
    <tr>
      <td width="400">&nbsp;Type of the Scheme (As of Now)</td>
      <td width="400">&nbsp;<?php echo "$rowMain[type_scheme]";?></td>
      </tr>
    <tr>
      <td>&nbsp;Name of the Schemes</td>
      <td>&nbsp;<?php echo "$rowMain[scheme_name]";?></td>
      </tr>
    <tr>
      <td>&nbsp;Year of Commissioning</td>
      <td>&nbsp;<?php if($rowMain['year_comm']==0){echo "Not Provided";}else{echo "$rowMain[year_comm]";}?></td>
      </tr>
    <tr>
      <td>&nbsp;Capital Cost (in <img src="images/26rup1.jpg" width="10"> Lakh)</td>
      <td>&nbsp;<?php echo "$rowMain[capital_cost]";?></td>
      </tr>
	  <tr>
      <td>&nbsp;Schemes Sanctioned Under</td>
      <td>&nbsp;<?php echo "$rowMain[scheme_sanction]";?></td>
      </tr>
  </table>
  </div>   <!-- End of section1  -->
  <!-- Start of Inner Div  -->
 <!-- End of inner div-->
</td></tr>
<tr>
<td background="images/title.gif">
  <a href="javascript:animatedcollapse.toggle('section2')">
  <div class="section_heading">&nbsp;2. Location Details</div></a>
  </td></tr>
  <tr><td>
  <div id="section2"  class="section_format">	
  <table border="1">
    <tr>
      <td colspan="5">&nbsp;</td>
      </tr>
    <tr>
      <td width="292">&nbsp;District</td>
      <td width="160">&nbsp;<?php $id="$rowMain[district_id]"; echo getName('district',$id);?></td>
      <td width="146">&nbsp;Block</td>
      <td colspan="2">&nbsp;<?php $id="$rowMain[block_id]"; echo getName('block',$id);?></td>
    </tr>
    <tr>
      <td>&nbsp;Gram Panchayat</td>
      <td>&nbsp;<?php  $id="$rowMain[panchayat_id]"; echo wordwrap(getName('panchayat',$id), 20, "\n", true);?></td>
      <td>&nbsp;Village Name</td>
      <td colspan="2">&nbsp;<?php $id="$rowMain[village_id]"; echo wordwrap(getName('village',$id), 20, "\n", true);?></td>
    </tr>
    <tr>
      <td>&nbsp;Census Village Code</td>
      <td>&nbsp;<?php echo wordwrap($rowMain['census_vil_code'], 20, "\n", true);?></td>
      <td>&nbsp;Referenece Id</td>
      <td colspan="2">&nbsp;<?php echo "$rowMain[form_id]";?></td>
    </tr>
    <tr>
      <td>&nbsp;Population Benefited (as per 2001 census)</td>
      <td>&nbsp;<?php echo "$rowMain[population_benefited]";?></td>
      <td>&nbsp;Present Population</td>
      <td colspan="2">&nbsp;<?php echo "$rowMain[present_population]";?></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="5">&nbsp;Habitation (MH/OH) Covered</td>
      </tr>
    <tr>
      <td>&nbsp;Name of Habitation</td>
      <td>&nbsp;Code No. (As per IMIS)</td>
      <td>&nbsp;Type MH/ OH</td>
      <td width="72">No. of HP </td>
      <td width="76">No. of SP </td>
    </tr>
	<?php
				$qryHabit="select * from tbl_dtls_q2_habit where q2_id='$id1' order by habit_code asc";
				$resHabit=mysql_query($qryHabit);
				while($rowHabit=mysql_fetch_array($resHabit))
				{
				?>
    <tr>
      <td>&nbsp;<?php echo "$rowHabit[habit_name]";?></td>
      <td>&nbsp;<?php echo "$rowHabit[habit_code]";?></td>
      <td>&nbsp;<?php echo "$rowHabit[type_mh_oh]";?></td>
      <td>&nbsp;<?php echo "$rowHabit[hp_no]";?></td>
      <td>&nbsp;<?php echo "$rowHabit[sp_no]";?></td>
    </tr>
	<?php } ?>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table>
  </div>  <!-- End of section2  -->
  </td></tr>
  <tr><td width="780" background="images/title.gif"> 
   <a href="javascript:animatedcollapse.toggle('section3')">
   <div class="section_heading">&nbsp;3. Engineering Aspects</div></a>
 </td> </tr>
  <tr><td>
   <div id="section3" class="section_format">	
  <table border="1">
  <tr>
      <td colspan="2" align="right"><div style="float:right; padding-right:5px; border-left:1px solid #CCCCCC; width:35px"><a href="scheme_section3_q2.php?id=<?php echo $frm; ?>&&val=<?php echo $rowMain['DP_population']; ?>&&dis=<?php echo $dis; ?>" rel="facebox" style="text-decoration:none"><img src="images/edit.gif" border="0" title="EDIT RECORD" /></a></div></td>
      </tr>
    <tr>
      <td colspan="2"> &nbsp;Design Parameters</td>
      </tr>
    <tr>
      <td width="400">&nbsp;Population ( As per Design )</td>
      <td width="400">&nbsp;<?php echo "$rowMain[DP_population]";?></td>
      </tr>
    <tr>
      <td>&nbsp;Water Demand (As per Design ) in KLD</td>
      <td>&nbsp;<?php echo "$rowMain[DP_water_demand]";?></td>
      </tr>
	  <tr>
      <td colspan="2">&nbsp;</td>
      </tr>
  </table>
  </div>   <!-- End of section3  -->
 </td></tr>
<tr><td width="780" background="images/title.gif"> 
   <a href="javascript:animatedcollapse.toggle('section4')">
   <div class="section_heading">&nbsp;4. Water Source Detail</div></a>
 </td> </tr>
  <tr><td>
   <div id="section4" class="section_format">	
  <table border="1">
  <tr>
      <td colspan="12" align="right"><div style="float:right; padding-right:5px; border-left:1px solid #CCCCCC; width:35px"><a href="q2_hp.php?frm=<?php echo $frm;?>" rel="facebox" style="text-decoration:none"><img src="images/trash-can2-add.gif" border="0" title="ADD RECORD" /></a></div></td>
      </tr>
    <tr>
      <td colspan="12">&nbsp;4. Water Source Details</td>
      </tr>
    <tr>
      <td rowspan="2">Habitation Name</td>
      <td rowspan="2">Type of MH/OH</td>
      <td rowspan="2">Location of HP</td>
      <td rowspan="2">Functional Status</td>
      <td rowspan="2">Operational status</td>
      <td rowspan="2">Quality Status</td>
      <td rowspan="2">Yield</td>
      <td rowspan="2">Seasonal Fluctuation s in yield</td>
      <td colspan="2">Water Table Fluctuations (m)</td>
      <td colspan="2">&nbsp;</td>
      </tr>
    <tr>
      <td>Min</td>
      <td>Max</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
	<?php
		$qryHP="select * from tbl_dtls_q2_hp_status where q2_id='$frm' order by id";
		$resHP=mysql_query($qryHP);
		while($rowHP=mysql_fetch_array($resHP))
		{
		?>
    <tr>
      <td>&nbsp;<?php echo "$rowHP[habitation_name]";?></td>
      <td>&nbsp;<?php echo "$rowHP[type_mh_oh]";?></td>
      <td>&nbsp;<?php echo "$rowHP[location]";?></td>
      <td>&nbsp;<?php echo "$rowHP[functional_status]";?></td>
      <td>&nbsp;<?php echo "$rowHP[operational_status]";?></td>
      <td>&nbsp;<?php echo "$rowHP[quality_status]";?></td>
      <td>&nbsp;<?php echo "$rowHP[yield]";?></td>
      <td>&nbsp;<?php echo "$rowHP[seasonal_fluctuation]";?></td>
      <td>&nbsp;<?php echo "$rowHP[water_table_min]";?></td>
      <td>&nbsp;<?php echo "$rowHP[water_table_max]";?></td>
      <td><a href="edit_q2_hp.php?var=<?php echo $rowHP['id'];?>& loc=<?php echo $rowHP['q2_id'];?>" rel="facebox" style="text-decoration:none"><img src="images/edit.png" width="9" height="9" border="0" title="Edit individual record" /></a></td>
      <td><a href="delete_q2_hp.php?var=<?php echo $rowHP['habitation_name'];?>&&loc=<?php echo $rowHP['q2_id'];?>&&code=<?php echo $rowHP['hp_sp']; ?>" rel="facebox" style="text-decoration:none"><img src="images/b_drop.png" width="9" height="9" border="0" title="Delete individual record" /></a></td>
    </tr>
	<?php }?>
    <tr>
      <td colspan="12">&nbsp;</td>
      </tr>
  </table>
  </div>   <!-- End of section4  -->
  
</td></tr>
<tr><td width="780" background="images/title.gif"> 
   <a href="javascript:animatedcollapse.toggle('section5')">
   <div class="section_heading">&nbsp;5. Operational Aspects</div></a>
 </td> </tr>
  <tr><td>
   <div id="section5" class="section_format">	
  <table border="1">
    <tr>
      <td colspan="4" align="right"><div style="float:right; padding-right:5px; border-left:1px solid #CCCCCC; width:35px"><a href="q2_operational.php?frm=<?php echo $frm;?>" rel="facebox" style="text-decoration:none"><img src="images/edit.gif" border="0" title="EDIT RECORD" /></a></div></td>
      </tr>
    <tr>
      <td width="378">&nbsp;Current status of schemes</td>
      <td colspan="3">&nbsp;<?php echo "$rowMain[OA_current_status]";?></td>
      </tr>
    <tr>
      <td>&nbsp;Operational Status (Number of months remaining operational)</td>
      <td colspan="3">&nbsp;<?php echo "$rowMain[OA_operational_status]";?></td>
      </tr>
    <tr>
      <td>&nbsp;Annual Operation &amp; Maintenance Cost (In <img src="images/26rup1.jpg" width="10">)</td>
      <td width="127">&nbsp;FY 2009 - 10 </td>
      <td width="124">&nbsp;FY 2008 - 09</td>
      <td width="123">&nbsp;FY 2007 - 08</td>
    </tr>
    <tr>
      <td>&nbsp;Man Power Cost</td>
      <td>&nbsp;<?php echo "$rowMain[manpower_cost_09_10]";?></td>
      <td>&nbsp;<?php echo "$rowMain[manpower_cost_08_09]";?></td>
      <td>&nbsp;<?php echo "$rowMain[manpower_cost_07_08]";?></td>
    </tr>
	  <tr>
      <td>&nbsp;Material Cost - Repairs</td>
      <td>&nbsp;<?php echo "$rowMain[material_cost_09_10]";?></td>
      <td>&nbsp;<?php echo "$rowMain[material_cost_08_09]";?></td>
      <td>&nbsp; <?php echo "$rowMain[material_cost_07_08]";?></td>
	  </tr>
	   <tr>
      <td>&nbsp;Preventive Maintenance Mechanisms in Place</td>
      <td colspan="3">&nbsp;<?php echo "$rowMain[maintenence_machanism]";?></td>
      </tr>
	   <tr>
	     <td colspan="4">&nbsp;</td>
	     </tr>
	   <tr>
	     <td colspan="4">&nbsp;Complaints Redressal Mechanism</td>
	     </tr>
	   <tr>
	     <td>&nbsp;1. Existing Reporting system </td>
	     <td colspan="3">&nbsp;<?php echo "$rowMain[existing_reporting_system]";?></td>
	     </tr>
	   <tr>
	     <td>&nbsp;2. Time Taken to address the complaint </td>
	     <td colspan="3">&nbsp;<?php echo "$rowMain[time_taken]";?></td>
	     </tr>
	   <tr>
	     <td colspan="4">&nbsp;</td>
	     </tr>
	   <tr>
	     <td colspan="4">&nbsp;Constraint / Issues
			Faced by PHED officials</td>
	     </tr>
	   <tr>
	     <td colspan="4">&nbsp;</td>
	     </tr>
	   <tr>
	     <td>&nbsp;Institutional</td>
	     <td colspan="3">&nbsp;<?php echo "$rowMain[constraint_institutional]";?></td>
	     </tr>
	   <tr>
	     <td>&nbsp;Financial</td>
	     <td colspan="3">&nbsp;<?php echo "$rowMain[constraint_financial]";?></td>
	     </tr>
	   <tr>
	     <td>&nbsp;Operational</td>
	     <td colspan="3">&nbsp;<?php echo "$rowMain[constraint_operational]";?></td>
	     </tr>
	   <tr>
	     <td colspan="4">&nbsp;</td>
	     </tr>
  </table>
  </div>   <!-- End of section5  --> 
  
  
  </td></tr>
<tr><td background="images/title.gif"> 
   <a href="javascript:animatedcollapse.toggle('section6')">
   <div class="section_heading">&nbsp;6. Critical Habitation</div>
   </a>
 </td> </tr>
  <tr><td> 
   <div id="section6" class="section_format">	
  <table border="1">
    <tr>
      <td colspan="4">&nbsp;</td>
	  
      </tr>
	  <tr>
      <td width="98">&nbsp;Habitation Name</td>
      <td width="98">&nbsp;Habitation Type</td>
      <td width="780">&nbsp;Critical</td>
	  <td width="780">&nbsp;</td>
    </tr>
	  <?php
		$qryCritical="select * from tbl_dtls_q2_critical where q2_id='$frm' order by critical_hcode asc";
		$resCritical=mysql_query($qryCritical);
		$i=1;
		while($rowCritical=mysql_fetch_array($resCritical))
		{
		?>
    
    <tr> 
      <td>&nbsp;<?php echo "$rowCritical[critical_hname]";?></td>
      <td>&nbsp;<?php echo "$rowCritical[type_habit]";?></td>
	  <td> &nbsp; <?php echo "$rowCritical[critical]";?> </td> 
	  <td width="15" align="center"><a href="critical_edit_view_q2.php?var=<?php echo $rowCritical['id'];?>" rel="facebox" style="text-decoration:none"><img src="images/edit.png" width="10" height="10" border="0" title="Edit individual record" /></a></td>
	 </tr> 
      <tr>
	  <?php
	if($rowCritical['critical']!="no")
	{
	?>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>
							<table border="1" id="table16" style="width:600px;">
							<tr>
								<td width="597" >
								&nbsp; 
								Critical Village in terms of quality </td>
							</tr>
							<tr>
								<td>&nbsp;<?php echo "$rowCritical[CH_quality]";?></td>
							</tr>
							<tr>
								<td>&nbsp;
								Critical Village in terms of quantity </td>
							</tr>
							<tr>
								<td>&nbsp;<?php echo "$rowCritical[CH_quantity]";?></td>
				    		</tr>
						</table>
						</td>
						<td>&nbsp;</td>
			</tr>
	
    
	<?php }}?>
    <tr>
      <td colspan="3">&nbsp;</td>
      </tr>
   
  </table>
  </div>   <!-- End of section6 -->
</td></tr>
<tr><td background="images/title.gif"> 
   <a href="javascript:animatedcollapse.toggle('section7')">
   <div class="section_heading">&nbsp;7. Water Supply by Tankers</div>
   </a>
 </td> </tr>
  <tr><td>
   <div id="section7" class="section_format">	
  <table border="1">
    <tr>
      <td colspan="7">&nbsp;</td>
      </tr>
	  <tr>
      <td width="98">&nbsp;Habitation Name</td>
      <td width="98">&nbsp;Habitation Type</td>
      <td width="67">&nbsp;Tanker Nos.</td>
      <td width="132">&nbsp;Quantity (KL)</td>
      <td width="122">&nbsp;Area Covered</td>
	   <td width="61">&nbsp;Todate</td>
	   <td width="47">&nbsp;From date</td>
	   <td width="15">&nbsp;</td>
	  </tr>
	  <?php
						$qryTanker="select * from tbl_dtls_q2_tanker where q2_id='$frm' order by habitation_code asc";
						$resTanker=mysql_query($qryTanker);
						while($rowTanker=mysql_fetch_array($resTanker))
						{
					?>
    <tr>
      <td>&nbsp;<?php echo "$rowTanker[habitation_name]";?></td>
      <td>&nbsp;<?php echo "$rowTanker[type_habit]";?></td>
      <td>&nbsp;<?php echo "$rowTanker[total_tanker_no]";?></td>
      <td>&nbsp;<?php echo "$rowTanker[water_quantity]";?></td>
      <td>&nbsp;<?php echo "$rowTanker[area_covered]";?></td>
	 <td>&nbsp;<?php echo "$rowTanker[to_date]";?></td>
      <td>&nbsp;<?php echo "$rowTanker[from_date]";?></td>
	  <td align="center"><a href="tanker_supply_edit_q2.php?var=<?php echo $rowTanker['id'];?>" rel="facebox" style="text-decoration:none"><img src="images/edit.png" width="9" height="9" border="0" title="Edit individual record" /></a></td>
    </tr>
    <?php
	}?>
		  <tr>
      <td colspan="7">&nbsp;</td>
      </tr>
  </table>
  </div>   <!-- End of section7  -->
</td></tr>

</table>
</div>